package com.darren.framework.entity;

import com.darren.framework.utils.Constant;

public class ResponseJSON {
	
	private Integer status = 0;
	private String message = "success";
	private Object data = null;

	public ResponseJSON(){

	}
	
	public ResponseJSON(int status, String message){
		this.status = status;
		this.message = message;
	}

	public ResponseJSON(Integer status, String message, Object data) {
		this.status = status;
		this.message = message;
		this.data = data;
	}

	public ResponseJSON set(int status, String message){
		this.status = status;
		this.message = message;
		return this;
	}

	public ResponseJSON set(int status, String message, Object data){
		this.status = status;
		this.message = message;
		this.data = data;
		return this;
	}

	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public Object getData() {
		return data;
	}
	public ResponseJSON setData(Object data) {
		this.data = data;
		return this;
	}
	
	public static ResponseJSON defaultFailedResponse(){
		return new ResponseJSON(Constant.STATUS_FAIL,Constant.STATUS_FAIL_MESSAGE,null);
	}
	
	public static ResponseJSON defaultSuccessResponse(){
		return new ResponseJSON(Constant.STATUS_SUCCESS,Constant.STATUS_SUCCESS_MESSAGE,null);
	}
	
	public static ResponseJSON defaultSuccessResponse(Object data){
		return new ResponseJSON(Constant.STATUS_SUCCESS,Constant.STATUS_SUCCESS_MESSAGE,data);
	}

	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder("{");
		sb.append("\"status\":")
				.append(status);
		sb.append(",\"message\":\"")
				.append(message).append('\"');
		sb.append(",\"data\":")
				.append(data);
		sb.append('}');
		return sb.toString();
	}
}
